﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DoAn.admin
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private DataClassesDoAnDataContext dc = new DataClassesDoAnDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.RepeaterHangDienThoai.DataSource = this.dc.hangdienthoais.ToList();
                this.RepeaterHangDienThoai.DataBind();
            }
        }

        protected void LinkButtonXoa_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lb = (LinkButton)sender;
                HiddenField hd = (HiddenField)lb.Parent.FindControl("HiddenFieldMaHang");
                hangdienthoai hdt = this.dc.hangdienthoais.Single(h => h.mahang == Convert.ToInt32(hd.Value));
                this.dc.hangdienthoais.DeleteOnSubmit(hdt);
                this.dc.SubmitChanges();
                this.RepeaterHangDienThoai.DataSource = this.dc.hangdienthoais.ToList();
                this.RepeaterHangDienThoai.DataBind();
                this.message_error.Visible = false;
                this.message_success.Visible = true;
            }
            catch
            {
                this.message_error.Visible = true;
                this.message_success.Visible = false;
            }
        }

    }
}
